package cn.lc.taotao.service.impl;

import cn.lc.taotao.mapper.TbItemMapper;
import cn.lc.taotao.pojo.EasyUIDataGridResult;
import cn.lc.taotao.pojo.TbItem;
import cn.lc.taotao.pojo.TbItemExample;
import cn.lc.taotao.service.ItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: luochao
 * Date: 2017/11/21 0021
 * Time: 下午 2:41
 */
@Service
public class ItemServiceImpl implements ItemService {

    @Autowired
    private TbItemMapper itemMapper;
    @Override
    public TbItem getItemById(Long itemId) {
        return itemMapper.selectByPrimaryKey(itemId);
    }

    @Override
    public EasyUIDataGridResult getItemList(Integer page, Integer rows) {
        //分页处理
        PageHelper.startPage(page,rows);
        //创建查询的实例
        TbItemExample example = new TbItemExample();
        //查询商品列表
        List<TbItem> tbItems = itemMapper.selectByExample(example);
        //封装到page类中
        return new EasyUIDataGridResult(tbItems);
    }
}
